package com.tsxy.mall.service.impl;

import com.tsxy.mall.entity.BookSort;
import com.tsxy.mall.mapper.BookMapper;
import com.tsxy.mall.mapper.BookSortMapper;
import com.tsxy.mall.service.BookService;
import com.tsxy.mall.service.BookSortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BookSortServiceImpl implements BookSortService {

    @Resource
    BookSortMapper bookSortMapper;
    @Resource
    BookService bookService;


    @Override
    public List getAllSortCludeBook() {
        List<BookSort> sort = bookSortMapper.getAllSort();
        sort.forEach(e -> {
            e.setBooks(bookService.getBooksByParentSortId(e.getId()));
        });
        return sort;
    }

    @Override
    public List getAllSort() {
        return bookSortMapper.getAllSort();
    }
}
